package com.zhu.wx.factory;

import com.zhu.wx.context.ApplicationContextUtils;
import com.zhu.wx.dict.WxEventEnum;
import com.zhu.wx.dict.WxRecEnum;
import com.zhu.wx.dict.WxResEnum;
import com.zhu.wx.strategy.WxRecStrategy;
import com.zhu.wx.strategy.WxResStrategy;

/**
 * 策略工厂类
 * 作用：主要创建策略
 */
public class StrategyFactory implements Factory {
    /**
     * 创建参数处理策略
     *
     * @param strategyEnum
     * @return
     */
    @Override
    public WxRecStrategy createStrategy(WxRecEnum strategyEnum) {
        return ApplicationContextUtils.getBean(strategyEnum.getClazz());
    }

    /**
     * 创建事件处理策略
     *
     * @param strategyEnum
     * @return
     */
    @Override
    public WxRecStrategy createStrategy(WxEventEnum strategyEnum) {
        return ApplicationContextUtils.getBean(strategyEnum.getClazz());
    }

    /**
     * 创建返回结果处理策略
     *
     * @param strategyEnum
     * @return
     */
    @Override
    public WxResStrategy createStrategy(WxResEnum strategyEnum) {
        return ApplicationContextUtils.getBean(strategyEnum.getClazz());
    }

}
